(function() {

	var app = angular.module('app2', [])

	app
	        .controller(
	                'SimpleController',
	                [
	                        '$scope',
	                        '$http',
	                        function($scope, $http) {
	                        	delete $http.defaults.headers.common['X-Requested-With'];
		                        // alert('yay controller loaded !');
		                        
		                        $scope.responseFromDummy = "dummy value";
		                        $scope.responseFromService = "dummy value";
		                        $scope.responseFromYahoo = "dummy yahoo value";
		                        
		                        var dummyUrl = 'http://default-environment-2xgz38vab8.elasticbeanstalk.com/log/get/2359';
		                        var localUrl = 'http://localhost:7001/baby-rest-services/log/get/6858';
		                        var yahooUrl = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.places%20where%20text%3D%22san%20francisco%2C%20ca%22&format=json&diagnostics=true&callback=';
		                        
		                        $http.get(dummyUrl, {
			                        headers : {
				                        'Accept' : 'application/json'
			                        }
		                        }) //
		                        .success(function(data, status, headers, config) {

			                        $scope.responseFromDummy = 'success' + angular.toJson(data);
		                        }) //
		                        .error(function(data, status, headers, config) {

			                        $scope.responseFromDummy = "error: [" + angular.toJson(status) + "] " + angular.toJson(data) ;
		                        });
		                        
		                        $http.get(localUrl, {
			                        headers : {
				                        'Accept' : 'application/json'
			                        }
		                        }) //
		                        .success(function(data, status, headers, config) {

			                        $scope.responseFromService = 'success' + angular.toJson(data);
		                        }) //
		                        .error(function(data, status, headers, config) {

		                        	$scope.responseFromService = "error: [" + angular.toJson(status) + "] " + angular.toJson(data) ;
		                        });
		                        
		                        $http.get(yahooUrl, {
			                        headers : {
				                        'Accept' : 'application/json'
			                        }
		                        }) //
		                        .success(function(data, status, headers, config) {

			                        $scope.responseFromYahoo = 'success' + angular.toJson(data.query.results);
		                        }) //
		                        .error(function(data, status, headers, config) {

		                        	$scope.responseFromYahoo = "error: [" + angular.toJson(status) + "] " + angular.toJson(data) ;
		                        });
	                        } ]);
	
})();